import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DeleteResult, Repository, UpdateResult } from 'typeorm';
import { Bk_Junior_College } from './bk_junior_college.entity';

@Injectable()
export class JuniorCollegeService {
    constructor(
        @InjectRepository(Bk_Junior_College)
        private readonly undergraduateRepository: Repository<Bk_Junior_College>
    ) { }

    async add(juniorCollege: any): Promise<Bk_Junior_College> {
        return await this.undergraduateRepository.save(juniorCollege);
    }

    async delete(id: number): Promise<DeleteResult> {
        return await this.undergraduateRepository.delete(id);
    }

    async update(id: number, juniorCollege: any): Promise<UpdateResult> {
        return await this.undergraduateRepository.update(id, juniorCollege);
    }

    async findAll(query: any): Promise<[Bk_Junior_College[], number]> {
        return await this.undergraduateRepository.findAndCount({ relations: ["discipline"], order: { id: "ASC" }, skip: query.skip, take: query.take });
    }
}
